﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace dsvn
{
    class Program
    {
        static void Main(string[] args)
        {
            var basePath = string.Empty;
            if (args != null && args.Length > 0)
                basePath = args[0];
            if (string.IsNullOrWhiteSpace(basePath))
                goto Label_Help;
            if (!Directory.Exists(basePath))
                goto Label_Help;

            try
            {
                Directory.EnumerateDirectories(basePath, ".svn", SearchOption.AllDirectories)
                       .ToList()
                       .ForEach(path =>
                       {
                           ford(path, null);
                       });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }


        Label_Help:
            Console.WriteLine("要删除svn文件的文件夹路径。dsvn c:\\xx");
        }
        static void ford(string path, DirectoryInfo di)
        {
            DirectoryInfo d = di;
            if (!string.IsNullOrEmpty(path))
                d = new DirectoryInfo(path);
            d.Attributes = FileAttributes.Normal;
            d.GetDirectories().ToList().ForEach(p => { ford(null, p); });
            d.GetFiles().ToList().ForEach(p => { p.Attributes = FileAttributes.Normal; p.Delete(); });
            Console.WriteLine("-------delete  " + (path ?? di.FullName));
            d.Delete();
        }
    }
}
